const { Sequelize, Model } = require('sequelize')
const { sequelize } = require('../../core/db')

class User extends Model {}

User.init({
  id: {
    type: Sequelize.INTEGER,
    autoIncrement: true,
    primaryKey: true
  },
  userName: {
    type: Sequelize.STRING(30),
    unique: true
  },
  password: Sequelize.STRING(50),
  loginCount: {
    type: Sequelize.INTEGER,
    defaultValue: 0
  }
}, {
  sequelize,
  tableName: 'User',
  paranoid: true  // 会自动增加 deleteAt字段，实行软删除
})

module.exports = {
  User
}